﻿using CPPEI.Coolzon.Common;
using CPPEI.Coolzon.Data;
using CPPEI.Coolzon.Service.Contract;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CPPEI.Coolzon.Server.ServiceImplement
{
    /// <summary>
    /// 请求重置场景处理
    /// </summary>
    public class ReqResetSceneHandler : BaseHandler<ReqResetSceneData, RespResetSceneData>
    {
        public ReqResetSceneHandler()
            : base(RESPONSE_SCENARIO.SETTING, RESPONSE_COMMAND.SETTING.RESETSCENE)
        {
        }

        protected override RespResetSceneData OnHandle(Data.MainServiceData.Request request, ReqResetSceneData requestData)
        {
            RespResetSceneData responseData = new RespResetSceneData();
            CacheData.ControlDomain domain = CacheData.ServerData.Instance.GetDomain(request.Header.DomainId);
            if (domain != null)
            {
                // 将场景信息添加到域中
                CacheData.SceneState sceneState = domain.GetOrAddScene(requestData.SceneName);
                sceneState.HorizontalLoopOffset = 0;
                responseData.IsSuccess = true;
            }
            else
            {
                responseData.IsSuccess = false;
                responseData.Message = "未发现控制域";
            }
            return responseData;
        }
    }
}
